<%@page import="java.util.Date"%>
<%@page import="java.util.function.Supplier"%>
<%@page import="java.text.SimpleDateFormat"%>
<%@page import="com.ldl.vo.LdlArticleVO"%>
<%@page import="java.util.List"%>
<%@ page language="java" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<title></title>
<jsp:include page="/admin/head.jsp"></jsp:include>
</head>
<body>
	<!-- 导航条 -->
	<jsp:include page="/admin/header.jsp"></jsp:include>
	<!--左边菜单-->
	<jsp:include page="/admin/left-menu.jsp"><jsp:param value="2" name="index"/></jsp:include>
	<!--底部-->
	<jsp:include page="/admin/footer.jsp"></jsp:include>

	<!--中间-->
	<section>
		<nav aria-label="breadcrumb">
			<ol class="breadcrumb">
				<li class="breadcrumb-item">管理首页</li>
				<li class="breadcrumb-item">内容管理</li>
				<li class="breadcrumb-item active">新闻列表</li>
			</ol>
		</nav>

		<form class="form-inline">
			<div class="form-group mx-sm-1 mb-2">
				<label class="sr-only">用户姓名：</label> <select class="form-control">
					<option value="">全部</option>
				</select>
			</div>
			<div class="form-group mx-sm-1 mb-2">
				<label class="sr-only">关键字：</label> <input type="text"
					class="form-control" placeholder="搜索关键字">
			</div>
			<button type="submit" class="btn btn-primary mb-2">
				<i class="fa fa-search"></i>
			</button>
			<a href="#" class="btn btn-success ml-auto mr-2 mb-2"><i
				class="fa fa-plus"></i></a>
			<div class="form-group mx-sm-1 mb-2 pr-2">
				<label class="sr-only">数量：</label> <select id="numSelect"
					class="form-control">
					<option value="">显示条数</option>
					<option value="1">每页1条</option>
					<option value="5">每页5条</option>
					<option value="10">每页10条</option>
					<option value="20">每页20条</option>
				</select>
			</div>
		</form>
		<div class="ml-2 mr-2">
			<table class="table table-striped table-bordered table-hover">
				<thead>
					<tr>
						<th scope="col">#</th>
						<th scope="col">新闻ID</th>
						<th scope="col">新闻标题</th>
						<th scope="col">来源</th>
						<th scope="col">发布时间</th>
						<th scope="col">操作</th>
					</tr>
				</thead>
				<tbody>
					<%
						List<LdlArticleVO> list = (List<LdlArticleVO>) request.getAttribute("list");
						for (int i = 0; i < list.size(); i++) {
							LdlArticleVO vo = list.get(i);
							pageContext.setAttribute("vo", vo);
							pageContext.setAttribute("i", i);
					%>
					<tr>
						<th scope="row">${i+1 }</th>
						<td>${vo.getArticleId() }</td>
						<td>${vo.getArticleTitle() }</td>
						<td>${vo.getArticleWorker() }</td>
						<td>${vo.getArticleTime() }</td>
						<td class="p-1"><div class="dropdown">
								<button
									class="btn btn-outline-primary btn-block dropdown-toggle"
									type="button" data-toggle="dropdown">操作</button>
								<div class="dropdown-menu dropdown-menu-right">
									<a class="dropdown-item" target="_blank" href="news-.htm">查看</a>
									<a class="dropdown-item" href="admin/article/update.jsp?id=">修改</a>
									<a class="dropdown-item _delete" data-index=""
										href="javascript:void(0);">删除</a>
								</div>
							</div></td>
					</tr>
					<%
						}
					%>
				</tbody>
			</table>
		</div>
	</section>
	<script type="text/javascript">
	var numSelect = document.getElementById("numSelect");
	numSelect.onchange = function(){
		window.location="admin/news-list.let?len="+this.value;
	}
</script>
</body>
</html>
<%!
	//private  SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm");
	private ThreadLocal<SimpleDateFormat> format = ThreadLocal.withInitial(new Supplier<SimpleDateFormat>(){
		public SimpleDateFormat get(){
			return new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
		}
	});

	private String format(Date date){
		if(date==null){
			return "-";
		} else {
			return format.get().format(date);
		}
	}

%>